package com.prj.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data
public class Result<T> {

    @Schema(description = "请求返回码")
    private Integer code;

    @Schema(description = "请求返回体")
    private T data;

    @Schema(description = "请求返回消息")
    private String message;

    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setMessage("success");
        result.setData(data);
        return result;
    }

    public static <T> Result<T> error(String message) {
        Result<T> result = new Result<>();
        result.setCode(-999);
        result.setMessage(message);
        return result;
    }
}

